<?php include_once("../../common/common_setting_unit.php");         // 引入通用的设置文件 ?>
<?php include_once("controller/detail-list.php");                     // 当前页面的控制器 ?>
<?php include_once("detail-list-function.php"); ?>


<?php include_once(ROOT_PATH_ . "/controller/common/module/head.php"); // 引入通用的头部 ?>
<link href="asset/css/style.css" rel="stylesheet" type="text/css"/>



<body>

<div id="topbar">
<?php include ROOT_PATH_ . '/controller/common/module/topbar.php'; ?></div>



<div id="container">
<!--Container端點01-->
<div id="maincontent" class="list">
<!--maincontent端點01-->



<div id="sidebar">
    <?php include ROOT_PATH_ . '/controller/common/module/sidebar.php'; ?>
</div>


<div id="content">

    <!--标题设定-->
    <?php $page_title='产品列表';?>
    <?php include $_SERVER['DOCUMENT_ROOT']. '/controller/common/module/mod-page-title.php'; ?>





    <div class="select-box layui-form clearfix <? echo $system_part ?>">
        <form action="detail-list.php" >

            <div class="layui-form-item">
                <label class="layui-form-label">关键词</label>
                <div class="layui-input-block">
                    <input type="text"  name="select_keywords" placeholder="名称" autocomplete="off" class="layui-input" value="<? echo $_REQUEST['select_keywords']?>" >
                </div>
            </div>

       <?php
	   $cat_result = mysql_query("select * from ".$table_Prefix."term where belong = '".$sys_belong."' and interm = 'root' and publish = 1 ");

  ?>
            <div class="layui-form-item search-term">
                <label class="layui-form-label">分类</label>
                <div class="layui-input-block">
                    <select name="cat_id">
                       <option value="0" <?php if($_REQUEST['cat_id'] == 0){ echo 'selected="selected"';}?> >请选择分类</option>
                       <?php

					   while ($cat = mysql_fetch_array($cat_result)) { //一级
					   ?>
                       <option value="<?php echo $cat['nid']?>" <?php if($_REQUEST['cat_id'] == $cat['nid']){ echo 'selected="selected"';}?>><?php echo $cat['name']?></option>
                       <?php

					   	$cat2_result = mysql_query("select * from ".$table_Prefix."term where belong = 'product' and interm = 'term1' and publish = 1 and term1 =  ".$cat['nid']);

							while ($cat2 = mysql_fetch_array($cat2_result)) { //二级
						?>
								<option value="<?php echo $cat2['nid']?>" <?php if($_REQUEST['cat_id'] == $cat2['nid']){ echo 'selected="selected"';}?>> - <?php echo $cat2['name']?></option>
					    <?php
								$cat3_result = mysql_query("select * from ".$table_Prefix."term where belong = 'product' and interm = 'term2' and publish = 1 and term2 =  ".$cat2['nid']);
                    	    	while ($cat3 = mysql_fetch_array($cat3_result)) { //三级
						?>
                        			<option value="<?php echo $cat3['nid']?>" <?php if($_REQUEST['cat_id'] == $cat3['nid']){ echo 'selected="selected"';}?>> - - <?php echo $cat3['name']?></option>
                        <?php
								}
							}
					   }
					   ?>

                    </select>
                </div>
            </div>

	   <?php
	   $brand_result = mysql_query("select * from ".$table_Prefix."brand where  status = '启用' order by nid asc ");
	   ?>
            <div class="layui-form-item search-brand">
                <label class="layui-form-label">品牌</label>
                <div class="layui-input-block">
                    <select name="brand_id" lay-search="">
                       <option value="0" <?php if($_REQUEST['brand_id'] == 0){ echo 'selected="selected"';}?>>请选择品牌</option>
                       <?php
					   while ($brand = mysql_fetch_array($brand_result)) { //一级
					   ?>
                           <option value="<?php echo $brand['nid']?>" <?php if($_REQUEST['brand_id'] == $brand['nid']){ echo 'selected="selected"';}?>>
                              <?php echo $brand['name']?>
                           </option>
                        <?php}?>

                    </select>
                </div>
            </div>

			<input type="hidden"  name="now_extender"  value="<?php echo $system_part;?>"/>
            <button class="layui-btn" ><i class="layui-icon">&#xe615;</i> 查找</button>

            <button class="layui-btn" type="reset" ><i class="layui-icon">&#x1006;</i> 重置</button>

            <br class="clearfloat"/>
        </form>

        <br class="clearfloat"/>
    </div>



 <!-- 用$system_part .list_boxes来控制来到确认板块信息显示-->
<div class="list-box clearfix <? echo $system_part ?>">

        <hr/>



<div class="list-boxes">



    <table class="layui-table layui-form">
        <colgroup>
            <col width="20">
            <col>
            <col width="100" class="publish">
            <col width="300">
        </colgroup>
        <thead>
        <tr>
            <th> </th>

            <th>资料</th>
            <th class="publish">发布</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>

        <?php for ($i = 0; $i < count($detail_nid); $i++) {
        ?>

        <tr id="item<?echo $detail_nid[$i]?>">
            <td >
                 <input type="checkbox" name="nid[]"
                        value="<?echo $detail_nid[$i]?>"
                        lay-skin="primary"
                        lay-filter="nid-filter"
                 >
<!--                 <span>--><?//echo $i+1?><!--</span>-->
            </td>

            <td> <ul class="list-boxing-data">
                    <li class="title-name">
                        <h6 ><label>名称：</label>
                        <a href="detail-edit.php?nid=<?php echo $detail_nid[$i] ?>&now_extender=<? echo $system_part ?>" <? if ($detail_publish[$i] != 1) { echo "class='title-notice'"; } ?>  style="font-size:14px; "><?php echo $detail_name[$i] ?></a>
                        </h6>
                    </li>

                </ul>
            </td>











            <td class="publish">
                <li >

                         <?if ($detail_publish[$i] == 1) { echo "发布"; }else{ echo '隐藏';}?>
                </li>

            </td>

<td>



<div>

<a href="javascript:void(0)"  class="delete layui-btn  layui-btn-sm" onclick="delete_list(<?php echo $detail_nid[$i]?>,'detail-delete')" > <i class="layui-icon">&#xe640;</i> 删除</a>
<a href="detail-edit.php?nid=<?php echo $detail_nid[$i] ?>&now_extender=<? echo $system_part ?>&nowpageid=<? echo $_REQUEST['nowpageid'] ?>&brand_id=<? echo $_REQUEST['brand_id'] ?>&sortby=<? echo $_REQUEST['sortby'] ?>&term_nid=<? echo $trans_nid ?>" class="modify layui-btn  layui-btn-sm" > <i class="layui-icon">&#xe642;</i> 修改</a>
</div>




</td>



        </tr>
            <?php

        }
        ?>
        </tbody>
    </table>




</div>





</div>




<hr/>

 <?php include_once(ROOT_PATH_."/controller/modules/page.php"); ?>



<!--content端點01-->
</div>
<!--maincontent端點01-->
<br class="clearfloat"/>
</div>
<!--container端點01-->
</div>
<!--删除box-->
<?php include '../modules/deletebar.php'; ?>
<!--删除box end-->

<?php include  ROOT_PATH_."/controller/modules/footer.php"; ?>

<script charset="utf-8" src="asset/js/select_order_jump.js?version=20231021"></script>










<script>
    function delete_list(id,url)
    {

        //拼装处理删除的地址
        let delete_url="controller/"+url+".php?nid=" + id

        //拼装处理删除的地址
        let item='#item' + id




        layer.confirm('确认删除数据吗？', {
                cancel:function(index){layer.close(index)},
                btn: ['确定','取消'] //按钮
            }, function(){
                //ajax开始请求
                $.ajax({
                    type: 'post',
                    url: delete_url,
                    timeout: 5000,
                    success: function (res)
                    {
                        let result = JSON.parse(res);
                        if ('200' == result.status) {   //返回200表示成功,//删除遮罩图层
                            $(item).remove();//把id为txx 的表格删除
                            layer.msg('成功删除数据')
                            setTimeout(function() {
                                layer.close(index);
                            }, 3000);
                        } else {
                            layer.msg('删除数据失败，请刷新页面后重试')
                            //隐藏遮罩图层并解锁页面高度
                        }
                    },
                    error: function (xhr, status, error)
                    {
                        // 处理错误响应的逻辑
                        layer.msg('删除数据失败，请刷新页面后重试');
                        //隐藏遮罩图层并解锁页面高度
                    }
                });
            }
        )



    }



</script>




</body>
</html>
